package com.openbravo.pos.panels;

import com.openbravo.basic.BasicException;
import com.openbravo.data.loader.DataField;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.Datas;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

public class SQLTableModel extends AbstractTableModel
{
  private List m_aRows = new ArrayList();
  private DataField[] m_df;
  private Datas[] m_classes;

  public SQLTableModel(DataField[] paramArrayOfDataField)
  {
    this.m_df = paramArrayOfDataField;
    this.m_classes = new Datas[paramArrayOfDataField.length];
    for (int i = 0; i < paramArrayOfDataField.length; i++)
      switch (paramArrayOfDataField[i].Type)
      {
      case -6:
      case -5:
      case 4:
      case 5:
        this.m_classes[i] = Datas.INT;
        break;
      case -7:
      case 16:
        this.m_classes[i] = Datas.BOOLEAN;
        break;
      case 2:
      case 3:
      case 6:
      case 7:
      case 8:
        this.m_classes[i] = Datas.DOUBLE;
        break;
      case -1:
      case 1:
      case 12:
      case 2005:
        this.m_classes[i] = Datas.STRING;
        break;
      case 91:
      case 92:
      case 93:
        this.m_classes[i] = Datas.TIMESTAMP;
        break;
      case -4:
      case -3:
      case -2:
      case 2004:
        this.m_classes[i] = Datas.BYTES;
        break;
      case 0:
      case 70:
      case 1111:
      case 2000:
      case 2001:
      case 2002:
      case 2003:
      case 2006:
      default:
        this.m_classes[i] = Datas.OBJECT;
      }
  }

  public void addRow(DataRead paramDataRead)
    throws BasicException
  {
    Object[] arrayOfObject = new Object[this.m_classes.length];
    for (int i = 0; i < this.m_classes.length; i++)
      arrayOfObject[i] = this.m_classes[i].getValue(paramDataRead, i + 1);
    this.m_aRows.add(arrayOfObject);
  }

  public String getColumnString(int paramInt)
  {
    Object[] arrayOfObject = (Object[])(Object[])this.m_aRows.get(paramInt);
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < arrayOfObject.length; i++)
    {
      if (i > 0)
        localStringBuffer.append(", ");
      localStringBuffer.append(this.m_classes[i].toString(arrayOfObject[i]));
    }
    return localStringBuffer.toString();
  }

  public Class getColumnClass(int paramInt)
  {
    return this.m_classes[paramInt].getClassValue();
  }

  public String getColumnName(int paramInt)
  {
    return this.m_df[paramInt].Name;
  }

  public int getRowCount()
  {
    return this.m_aRows.size();
  }

  public int getColumnCount()
  {
    return this.m_df.length;
  }

  public Object getValueAt(int paramInt1, int paramInt2)
  {
    Object[] arrayOfObject = (Object[])(Object[])this.m_aRows.get(paramInt1);
    return arrayOfObject[paramInt2];
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.panels.SQLTableModel
 * JD-Core Version:    0.6.0
 */